//
//  HMComposeButton.swift
//  WeiBo
//
//  Created by Feng on 2017/6/12.
//  Copyright © 2017年 feng. All rights reserved.
//

import UIKit

class HMComposeButton: UIButton {

    override init(frame: CGRect) {
        super.init(frame: frame)
        
        titleLabel?.textAlignment = .center
        imageView?.contentMode = .center
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    //MARK: --子控件布局
    override func layoutSubviews() {
        super.layoutSubviews()
        
        //  如果执行transform动画不能使用frame，因为frame发生了改变，而bounds不会改变
        imageView?.frame.origin.x = 0
        imageView?.frame.origin.y = 0
        imageView?.frame.size.width = self.bounds.size.width
        imageView?.frame.size.height = self.bounds.size.width
        
        titleLabel?.frame.origin.x = 0
        titleLabel?.frame.origin.y = self.bounds.size.width
        titleLabel?.frame.size.width = self.bounds.size.width
        titleLabel?.frame.size.height = self.bounds.size.height - self.bounds.size.width
    }
}
